#!/usr/bin/env python2.5

import os, sys, anydbm, marshal

from twisted.python import log
from twisted.internet import reactor
from twisted.web import client
from twisted.internet import defer, task

from polarrose.amazon.sss import SimpleStorageService

if __name__ == "__main__":

    from twisted.internet import reactor

    def printResult(response):
        for bucket in response.buckets:
            print "%s %s" % (bucket.creationDate, bucket.name)
        reactor.stop()

    def printError(failure):
        print "failure: " + str(failure)
        reactor.stop()

    service = SimpleStorageService(key = os.environ.get("AWS_KEY"), secret = os.environ.get("AWS_SECRET"))
    service.listAllMyBuckets().addCallback(printResult).addErrback(printError)
    reactor.run()
    
